<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="java.util.HashSet"%>
<%@page import="java.util.Set"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="com.shsh.safemanage.model.ProblemTransfer"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.ProblemDao"%>

<%
	String theProblemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
	Long theProblemID = 0L;
	try {
		theProblemID = new Long(theProblemIDStr);
	} catch (Exception e) {
	}

	DepartmentDao theDepartmentDao = DaoCreator.createDepartmentDao();
	ProblemDao theProblemDao = DaoCreator.createProblemDao();
	Problem theProblem = theProblemDao.getProblemByID(theProblemID);
%>
<table align="center" border="1" width="99%" cellpadding="0"
	cellspacing="0">
	<tr>
		<td class="td1"><span
			style="margin-left: 30px; font-weight: bold">作业部（业务中心）：</span> <span><%=theProblem.getDepartment1Name()%></span>
			<span style="margin-left: 30px; font-weight: bold">装置：</span> <span><%=theProblem.getDepartment1Name()%></span>
		</td>
	</tr>
	<tr>
		<td class="td1"><span
			style="margin-left: 30px; font-weight: bold">通报内容标题：</span> <%=theProblem.getProblemTitle()%>
		</td>
	</tr>
	<tr>
		<td class="td1"><span
			style="margin-left: 30px; font-weight: bold">通报内容：</span> <br /> <span
			style="margin-left: 30px">问题内容：</span> <%=theProblem.getProblemContent()%>
			<br /> <span style="margin-left: 30px">整改措施：</span> <%=theProblem.getProblemZhenggai()%>
		</td>
	</tr>
	<tr>
		<td class="td1"><span
			style="margin-left: 30px; font-weight: bold">通报人及时间：</span> <span><%=theProblem.getDepartment1Name()%></span>
			<span style="margin-left: 20px"><%=theProblem.getWriteUserName()%></span>
			<span style="margin-left: 20px"><%=Util.formatDateTime(theProblem.getWriteTime())%></span>
		</td>
	</tr>
	<%
		List<ProblemTransfer> transferList = theProblemDao.getProblemTransferByProblemID(theProblemID);
		Set<String> nameSet = new HashSet<String>();
		StringBuilder sb = new StringBuilder();
		for (ProblemTransfer transfer : transferList) {
			nameSet.add(transfer.getTransferedUserName());
		}
		for (String name : nameSet) {
			if (sb.length() == 0) {
				sb.append(name);
			} else {
				sb.append(" " + name);
			}
		}
	%>
	<tr>
		<td class="td1"><span
			style="margin-left: 30px; font-weight: bold">问题被通知人：</span> <span><%=sb.toString()%></span>
		</td>
	</tr>
	<%
		for (ProblemTransfer transfer : transferList) {
			if (!transfer.isProcessed() || transfer.getFeedback() == null || transfer.getFeedback().length() == 0) {
				continue;
			}
			Department1 depart1 = theDepartmentDao.getDepartment1ByID(transfer.getTransferedUserDepartment1ID());
	%>
	<tr>
		<td class="td1"><span
			style="margin-left: 30px; font-weight: bold">【<%=depart1.getDepartmentName()%>】
		</span> <br /> <span style="margin-left: 30px;"><%=transfer.getFeedback()%></span>
			<br /> <span style="margin-left: 30px;"><%=transfer.getTransferedUserName()%></span>
			<span><%=Util.formatDateTime(transfer.getProcessTime())%></span></td>
	</tr>
	<%
		}
	%>
</table>

